/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.pub.model;

import java.sql.Clob;
import java.util.List;

import javacommon.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;

import com.tech15.core.model.Attach;

import cn.org.rapid_framework.util.DateConvertUtils;

/**
 * @author 胡作正 email:zuozhenghu@sina.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "PUB_INFO")
public class PubInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "公共信息";
	public static final String ALIAS_ID = "id";
	public static final String ALIAS_ZT = "主题";
	public static final String ALIAS_LB = "类别";
	public static final String ALIAS_NR = "内容";
	public static final String ALIAS_FBSJ = "发布时间";
	public static final String ALIAS_FBBM = "发布部门";
	public static final String ALIAS_FBR = "发布人";
	
	//date formats
	public static final String FORMAT_FBSJ = DATE_TIME_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * id       db_column: ID 
     */ 	
	@Length(max=32)
	private java.lang.String id;
    /**
     * 标题       db_column: BT 
     */ 	
	@Length(max=150)
	private java.lang.String bt;
	 /**
     * 主题       db_column: ZT 
     */ 	
	private Long zt;
    /**
     * 类别       db_column: LB 
     */ 	
	private Long lb;
    /**
     * 内容       db_column: NR 
     */ 	
	@Length(max=4000)
	private Clob nr;
    /**
     * 发布时间       db_column: FBSJ 
     */ 	
	
	private java.util.Date fbsj;
    /**
     * 发布部门       db_column: FBBM 
     */ 	
	
	private String fbbm;
    /**
     * 发布人       db_column: FBR 
     */ 	
	
	private Long fbr;
	
	/**
     * 是否置顶       db_column: ISTOP 
     */ 	
	@Max(127)
	private Integer istop;
	/**
     * 申请置顶（1是 2处理）       db_column: SQTOP 
     */ 	
	@Max(127)
	private Integer sqtop;
    /**
     * 置顶时间       db_column: TOPSJ 
     */ 	
	@Max(127)
	private Integer topsj;
	/**
     * 是否受控       db_column: ISAUTH 
     */ 	
	@Max(127)
	private Integer isauth;
	//columns END


	public PubInfo(){
	}

	public PubInfo(
		java.lang.String id
	){
		this.id = id;
	}

	

	public void setId(java.lang.String value) {
		this.id = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "uuid.hex")
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 32)
	public java.lang.String getId() {
		return this.id;
	}
	
	@Column(name = "BT", unique = false, nullable = true, insertable = true, updatable = true, length = 150)
	public java.lang.String getBt() {
		return this.bt;
	}
	
	public void setBt(java.lang.String value) {
		this.bt = value;
	}
	
	@Column(name = "Zt", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getZt() {
		return this.zt;
	}
	
	public void setZt(Long value) {
		this.zt = value;
	}
	
	@Column(name = "LB", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getLb() {
		return this.lb;
	}
	
	public void setLb(Long value) {
		this.lb = value;
	}
	
	@Column(name = "NR", unique = false, nullable = true, insertable = true, updatable = true, length = 4000)
	public Clob getNr() {
		return this.nr;
	}
	
	public void setNr(Clob value) {
		this.nr = value;
	}
	
	@Transient
	public String getFbsjString() {
		return DateConvertUtils.format(getFbsj(), FORMAT_FBSJ);
	}
	public void setFbsjString(String value) {
		setFbsj(DateConvertUtils.parse(value, FORMAT_FBSJ,java.util.Date.class));
	}
	
	@Column(name = "FBSJ", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getFbsj() {
		return this.fbsj;
	}
	
	public void setFbsj(java.util.Date value) {
		this.fbsj = value;
	}
	
	@Column(name = "FBBM", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public String getFbbm() {
		return this.fbbm;
	}
	
	public void setFbbm(String value) {
		this.fbbm = value;
	}
	
	@Column(name = "FBR", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getFbr() {
		return this.fbr;
	}
	
	public void setFbr(Long value) {
		this.fbr = value;
	}
	
	@Column(name = "ISTOP", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getIstop() {
		return this.istop;
	}
	
	public void setIstop(Integer value) {
		this.istop = value;
	}
	
	@Column(name = "SQTOP", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getSqtop() {
		return this.sqtop;
	}
	
	public void setSqtop(Integer value) {
		this.sqtop = value;
	}
	
	@Column(name = "TOPSJ", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getTopsj() {
		return this.topsj;
	}
	
	public void setTopsj(Integer value) {
		this.topsj = value;
	}
	
	@Column(name = "ISAUTH", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getIsauth() {
		return this.isauth;
	}
	
	public void setIsauth(Integer value) {
		this.isauth = value;
	}
	
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("Zt",getZt())
			.append("Lb",getLb())
			.append("Fbsj",getFbsj())
			.append("Fbbm",getFbbm())
			.append("Fbr",getFbr())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof PubInfo == false) return false;
		if(this == obj) return true;
		PubInfo other = (PubInfo)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	
	private String content;
	List<Attach> attach;
	private String fbsjBegin;
	private String fbsjEnd;
	private String dataname;
	private String uploadedAttachName;
	private List<PubInfoAuth> users;
	private Long[] userids;
	
	@Transient
	public String getUploadedAttachName() {
		return uploadedAttachName;
	}

	public void setUploadedAttachName(String uploadedAttachName) {
		this.uploadedAttachName = uploadedAttachName;
	}

	@Transient
	public String getDataname() {
		return dataname;
	}

	public void setDataname(String dataname) {
		this.dataname = dataname;
	}

	@Transient
	public String getFbsjBegin() {
		return fbsjBegin;
	}

	public void setFbsjBegin(String fbsjBegin) {
		this.fbsjBegin = fbsjBegin;
	}

	@Transient
	public String getFbsjEnd() {
		return fbsjEnd;
	}

	public void setFbsjEnd(String fbsjEnd) {
		this.fbsjEnd = fbsjEnd;
	}

	@Transient
	public List<Attach> getAttach() {
		return attach;
	}

	public void setAttach(List<Attach> attach) {
		this.attach = attach;
	}

	@Transient
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Transient
	public Long[] getUserids() {
		return userids;
	}

	public void setUserids(Long[] userids) {
		this.userids = userids;
	}

	@Transient
	public List<PubInfoAuth> getUsers() {
		return users;
	}

	public void setUsers(List<PubInfoAuth> users) {
		this.users = users;
	}
}

